#include"ui_widget.h"
#include "widget.h"


Widget::Widget(QWidget* parent)
    : QWidget(parent),ui(new Ui::Widget)

{
    ui->setupUi(this);
    setFixedSize(8 * 64, 8 * 64);
    pBox=new BoxGame;
    pMap = new QPainter(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::keyPressEvent(QKeyEvent* event)
{
    pBox->keyDown(event);
    if(pBox->gameover()){
        this->close();
    }

}

void Widget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);
    pMap->begin(this);
    pBox->drawMap(pMap);
    pMap->end();
    update();

}
